<template>
    <div class="wrapper">
        <div class="card" @click="goStatistics('/statistics')">
            <img class="bg" src="@/assets/posManageMent.png" alt="" />
            <div class="content">
                <div class="top">
                    <img class="left" src="@/assets/min.png" alt="" />
                    <span>终端总数</span>
                    <img class="right" src="@/assets/img.png" alt="" />
                </div>
                <div class="top center">
                    <img class="left" src="@/assets/min.png" alt="" />
                    <span>{{ posAll.totalActNum }}</span>
                </div>
                <div class="bottom">
                    <div class="left">
                        <span>昨日唤醒</span>
                        <span class="num">{{ posAll.ystdActNum }}</span>
                    </div>
                    <div class="center" />
                    <div class="right">
                        <span>昨日绑定</span>
                        <span class="num">{{ posAll.ystdBindNum }}</span>
                    </div>
                </div>
            </div>
        </div>
        <div class="admin">
            <div class="title">终端管理</div>
            <div class="adminItem">
                <div class="item" @click="goStatistics('/admin')">
                    <div class="left">
                        <img src="@/assets/manageMent1.png" alt="" class="icon" />
                    </div>
                    <div class="center">终端管理</div>
                    <div class="right">
                        <img src="@/assets/chevron-down@2x.png" alt="" class="icon" />
                    </div>
                </div>
                <div class="item" @click="goStatistics('/allot')">
                    <div class="left">
                        <img src="@/assets/manageMent2.png" alt="" class="icon" />
                    </div>
                    <div class="center">终端调拨</div>
                    <div class="right">
                        <img src="@/assets/chevron-down@2x.png" alt="" class="icon" />
                    </div>
                </div>
                <div class="item" @click="goStatistics('/allotBank')">
                    <div class="left">
                        <img src="@/assets/manageMent3.png" alt="" class="icon" />
                    </div>
                    <div class="center">终端回拨</div>
                    <div class="right">
                        <img src="@/assets/chevron-down@2x.png" alt="" class="icon" />
                    </div>
                </div>
                <div class="item" @click="goStatistics('/sateActive')">
                    <div class="left">
                        <img src="@/assets/manageMent4.png" alt="" class="icon" />
                    </div>
                    <div class="center">批量设置活动</div>
                    <div class="right">
                        <img src="@/assets/chevron-down@2x.png" alt="" class="icon" />
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import { appStatisPosAct } from '../../api/posManagement'

export default defineComponent({
    name: 'posManagement',
    setup() {
        const router = useRouter()
        const state = reactive({
            posAll: {
                totalActNum: 0,
                ystdActNum: 0,
                ystdBindNum: 0
            }
        })
        const goStatistics = url => {
            router.push({
                path: url
            })
        }
        const getAppStatisPosAct = () => {
            appStatisPosAct().then(res => {
                state.posAll = res.object
            })
        }
        getAppStatisPosAct()
        return {
            ...toRefs(state),
            goStatistics
        }
    }
})
</script>

<style lang="scss" scoped>
.wrapper {
    padding: 10px;
    .card {
        position: relative;
        .bg {
            width: 100%;
        }
        .content {
            position: absolute;
            top: 0;
            left: 0;
            height: 100%;
            width: 100%;
            padding: 10px;
            box-sizing: border-box;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            .top {
                display: flex;
                align-items: center;
                font-size: 0;
                .left {
                    width: 14px;
                }
                span {
                    font-size: 14px;
                    color: #ffffff;
                    margin: 0 10px;
                }
                .right {
                    width: 16px;
                }
            }
            .top.center {
                .left {
                    visibility: hidden;
                }
                span {
                    font-size: 40px;
                }
            }
            .bottom {
                display: flex;
                align-items: center;
                justify-content: space-around;
                font-size: 12px;
                line-height: 30px;
                color: #ffffff;
                .num {
                    margin-left: 10px;
                }
                .center {
                    border-left: 1px solid #ffffff;
                    height: 14px;
                    opacity: 1;
                }
            }
        }
    }
    .admin {
        background: #ffffff;
        border-radius: 6px;
        margin-top: 10px;
        .title {
            padding: 10px;
            border-bottom: 1px solid #cccccc;
        }
        .adminItem {
            padding: 0 10px;
            .item {
                display: flex;
                align-items: center;
                font-size: 0;
                padding: 10px 0;
                border-bottom: 1px solid #eeeeee;
                .left {
                    .icon {
                        width: 18px;
                    }
                }
                .center {
                    flex: 1;
                    padding: 0 10px;
                    font-size: 14px;
                }
                .right {
                    img {
                        width: 20px;
                    }
                }
            }
        }
    }
}
</style>
